package com.company.cloud.club.modules.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.company.cloud.club.modules.db.dao.PraiseMapper;
import com.company.cloud.club.modules.db.domain.Praise;
import com.company.cloud.club.modules.service.PraiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * *****************************************************************************
 * <p>
 * 功能名           ：com.qxzychina..service.impl
 * 系统名           ：
 * <p>
 * *****************************************************************************
 * Modification History
 * <p>
 * Date        Name                    Reason for Change
 * ----------  ----------------------  -----------------------------------------
 * 2020/7/18     zhangxu                 Created
 */
@Service
public class PraiseServiceImpl extends ServiceImpl<PraiseMapper, Praise> implements PraiseService {

    @Autowired
    private PraiseMapper praiseMapper;

    @Override
    public Praise getByCommentIdAndUserId(String commentId, Integer userId) {
        return baseMapper.selectByCommentIdAndUserId(commentId, userId);
    }

    @Override
    public Integer countByCommentId(String commentId) {
        return baseMapper.countByCommentId(commentId);
    }

    @Override
    public void deletePraise(String id) {
        praiseMapper.deletePraise(id);
    }

    @Override
    public void addPraise(String commentId) {
        praiseMapper.addPraise(commentId);
    }

    @Override
    public void subPraise(String commentId) {
        praiseMapper.subPraise(commentId);
    }

    @Override
    public Boolean isPraise(String commentId, Integer userId) {
        return null != baseMapper.selectByCommentIdAndUserId(commentId, userId);
    }

}